1. Field of the Invention
The present invention relates to a technique for compositing a plurality of images that are shot with different exposures, so as to generate an image with a wide dynamic range.
2. Description of the Related Art
In recent years, a high dynamic range (HDR) imaging (image compositing) function of shooting a plurality of images with different exposures and compositing these images so as to generate an image with a wide dynamic range is gathering attention as a technique for reducing a highlight-detail loss and a shadow-detail loss in dark areas due to a large difference in contrast. In general, because the dynamic ranges (contrast between the brightest and darkest areas) of CMOS image sensors or the like are narrower than the dynamic range in the realm of nature, a highlight-detail loss may occur in by far the brightest areas such as the area in sunlight, and a shadow-detail loss may occur in dark areas.
Reducing exposure during shooting in response to such a highlight-detail loss darkens the overall image and suppresses the occurrence of a highlight-detail loss, but instead a shadow-detail loss may occur in dark areas. On the other hand, increasing exposure in response to a shadow-detail loss brightens the overall image and suppresses the occurrence of a shadow-detail loss, but instead a highlight-detail loss may occur in bright areas.
HDR imaging can improve a highlight-detail loss and a shadow-detail loss in dark areas by shooting a plurality of images of the same composition with high and low exposures and compositing these images with weights assigned to low-exposed images in bright areas (e.g., highlight-detail loss) and weights assigned to high-exposed images in dark areas.
Here, consider the case of shooting a person with a background of a lighted-up fish tank in a place such as an aquarium where there is the fish tank in a substantially dark interior (backlight scene). In normal shooting, the fish tank has a highlight-detail loss because the person is shot with correct exposure, and if the fish tank is shot with correct exposure, the person will have a shadow-detail loss.
In this case, an image without a highlight-detail loss or a shadow-detail loss can be generated by using the HDR imaging function to composite an image that is shot with such an exposure that a person has no shadow-detail loss and an image that is shot with such an exposure that the fish tank has no highlight-detail loss. However, with the conventional HDR imaging function, in the case of shooting with such an exposure that a person has no shadow-detail loss, dark areas other than the person such as the wall and floor of the building are brightened, which ruins the special atmosphere of the aquarium.
In contrast, according to Japanese Patent Laid-Open No. 2009-065350, in the case of compositing an image that is shot so as to achieve correct exposure for the face region of a person and an image that is shot so as to achieve high exposure for the face region of the person, the ratio of compositing the image that has been shot with high exposure (hereinafter, “composite ratio”) is increased in the face region of the person, and the composite ratio of the high-exposed image is reduced with increasing distance from the person, so as to brighten only the person.
However, the distance from the person according to the above-described Japanese Patent Laid-Open No. 2009-065350 is merely a distance in an image plane and is not a kind of factor that changes the composite ratio in consideration of the depth of a scene. For this reason, flexible image compositing, such as brightening a person who is present in the background at the back of a main object as part of the background, or keeping darken an irrelevant person who is present in front of the main object, is impossible.